As a conventional method, there is a method (hereinafter referred to as “level conversion”) of converting each pixel of an input image by a function having an input/output relationship (hereinafter referred to as “level conversion function”) indicated by a solid line in FIG. 18, for example, for conversion of gradation characteristics of an image. In FIG. 18, a lateral axis indicates a pixel level (input level) l of an input image, and a vertical axis indicates a pixel level (output level) T(l) of an output image by the level conversion. Lmax indicates a maximum level which each pixel of an input/output image can obtain. A contrast of the image after the level conversion increases with an increase in a gradient of the level conversion function. In an example shown in FIG. 18, gradients of straight lines indicating the level conversion function in a high level from an input level lb as a border of the high level and in a low level from an input level ls as a border of the low level are smaller than a gradient in a medium level (from the input level ls to the input level lb). Therefore, in the level conversion using the function shown in FIG. 18, a contrast in the medium level is increased by sacrificing contrasts in the high level and the low level.
In addition to the level conversion function shown in FIG. 18, a level conversion function indicated by a solid line in FIG. 19 can be used. In the level conversion function shown in FIG. 19, a gradient of a straight line in the high level from an input level lk as a boundary of the high level is smaller than gradients in the low level and the medium level. Therefore, in the level conversion using the function shown in FIG. 19, the contrasts in the low level and the medium level can be increased by sacrificing the contrast in the high level. Further, compared with the functions shown in FIGS. 18 and 19, a more continuous level conversion function such as a gamma function shown in Mathematical Formula 1 or a LOG function shown in Mathematical Formula 2 may be used. In Mathematical Formula 1, “g” indicates a parameter for adjusting the gradient of the function.
Moreover, as another conventional method, there is a method of adaptively changing the level conversion function according to a frequency distribution of the pixel level of the input image, and as a typical example of the conventional method, a method called histogram equalization is cited. FIGS. 20A and 20B show a principle of the histogram equalization. In FIG. 20A, a lateral axis indicates a pixel level (input level) l of an input image, and a vertical axis indicates frequency (or cumulative frequency). Fmax indicates a maximum value of the cumulative frequency, which is a total number of pixels used for calculating the frequency. In the method, as shown in FIG. 20A, at first a frequency distribution H(l) relating to the pixel level l of the input image is produced, and then a cumulative frequency distribution C(l) is produced by the use of Mathematical Formula 3.
The vertical axis of the cumulative frequency distribution C(l) is normalized to a level range in which the output image can obtain by the use of Mathematical Formula 4 so as to produce a level conversion function T(l) (refer to FIG. 20B). By the use of the function T(l), a contrast in a region configured with a high frequency level (a region with a large area) can be increased.
When an inputted image is used in an environment where the dynamic range is smaller, that is, the number of bits representing the pixel level is smaller (for example, in the case of transmitting the image through a transmission line with a small number of bits, displaying the image on a display apparatus, or storing the image in memory), the dynamic range is required to be compressed. Conventionally, the same level conversion as the method described above is used to compress the dynamic range for such purpose. However, in this case, a maximum level of the output image of the level conversion function has a smaller value than that of the input image.
On the other hand, in literature of “Z. Rahman, et, alt.:“A Multiscale retinex for color rendition and dynamic range compression in Applications of Digital image Processing”, XIX Proc. SPIE 2847 (1996)”, a method (hereinafter referred to as “Multiscale retinex method”) of compressing the entire dynamic range by extracting and compressing a component of illumination light which is spatially and slightly changed by the use of a lowpass filter is proposed. A linear narrow-band lowpass filter is used to extract an illumination component. In the method, as shown in Mathematical Formula 5, a logarithm value of an input pixel value I(x, y) and a logarithm value of a lowpass filter output LPF(I(x, y)) are taken, and then the latter is subtracted from the former to compress the dynamic range.
In the above conventional level conversion methods, in order to prevent from producing an unnatural image, a level conversion function having a monotone increasing property is used. Therefore, there is a problem that when a contrast in any level range (the gradient of the level conversion function) is increased, conversely, contrasts in other level ranges declines.
Further, in the Multiscale retinex method, by sacrificing the monotone increasing property, an image with a higher contrast can be reproduced. However, there is a problem that when an illumination condition is suddenly switched, the linear filter cannot extract a change in the illumination condition, so a subjectively undesirable noise occurs.
For example, as shown in FIG. 21, when an image having two regions with different illumination conditions adjacent to each other (indicated by a solid line in the drawing) is filtered by the linear lowpass filter, a signal with an ambiguous boundary indicated by a thin broken line is obtained as a filter output. When the filter output is considered as the illumination component, in a region on a left side of an illumination boundary (B region), a portion near the boundary (BNB region) has a lower illumination level than a portion at a distance from the boundary (BFB region). The Mathematical Formula 5 is equivalent to dividing an input signal by the illumination component, and means that the larger the illumination component is, the more the input signal is compressed. Accordingly, overshoot occurs in the BNB region of a reproduced image (indicated by a thick broken line in the drawing). Conversely, it is considered that in a region on a right side of the illumination boundary (D region), a portion near the boundary (DNB region) has a higher illumination level than a portion at a distance from the boundary (DFB region), so undershoot occurs. In the Multiscale retinex method, in order to overcome the problem, a method of using a plurality of linear lowpass filters with different scales, and synthesizing results obtained by each of the lowpass filters by a linear load is used, but a weight for each scale is fixed, so the above problem cannot be sufficiently prevented.
Therefore, it is considered that a nonlinear filter such as, for example, an epsilon filter instead of the linear lowpass filter is used to extract the illumination component. The epsilon filter is superior in performance of storing an edge to the linear filter, so the illumination component can be effectively extracted from an image where different illumination lights exist. However, in a fixed threshold epsilon filter which is generally used to remove noise, a discontinuous waveform is generated in an output thereof in a neighborhood of the edge, so when the filter is used to compress the dynamic range, an unnatural image pattern which does not exist in an original image may be generated in a reproduced image after compression.
In view of the foregoing, it is an object of the invention to provide an image processing method and an image processing apparatus capable of appropriately extracting a boundary between a plurality of illuminations by the use of the epsilon filter in the case where the plurality of illuminations exist, and preventing from generating an unnatural image pattern so as to achieve subjectively preferable compression of the dynamic range.